package yannan.voiplock4ble.bean.ble;

import yannan.voiplock4ble.service.ble.BleUtils;

/**
 * 说明：解析报文工厂类
 * 作者：mainTel
 * 时间：2016/12/3 19:50
 * 备注：
 */
public class BleResponseFactory {
    public static BaseBleResponse create(byte[] response) {
        try {
            int order = response[6] & 0XFF;
            switch (order) {
                case BleUtils.ORDER_CONNECT_LOCK: //门锁链接
                    return new ConnectLock(response);
                case BleUtils.ORDER_GET_LOCK_INFO: //门锁信息
                    return new LockInfo(response);
                case BleUtils.APP_REGISTER_PWD_ID: //注册密码
                    return new AddPwd(response);
                case BleUtils.APP_GET_PW_LIST_ID: //密码列表
                    return new PwdUser(response);
                case BleUtils.APP_GET_LOCK_TIME_ID: //门锁时间
                    return new LockTime(response);
                case BleUtils.APP_SET_LOCK_TIME_ID: //设置门锁时间
                    return new SetLockTime(response);
                case BleUtils.APP_GET_UNLOCK_RECORD_ID://获取开锁记录
                    return new UnLockRecord(response);
                case BleUtils.APP_REGISTER_FINGER_ID: //注册指静脉
                    return new AddVein(response);
                case BleUtils.APP_GET_FINGER_LIST_ID: //全部指静脉列表
                    return new VeinKey(response);
                case BleUtils.APP_DELETE_FINGER_ID: //删除指静脉
                case BleUtils.APP_DELETE_PWD_ID: //删除密码
                    return new DelKey(response);
                case BleUtils.APP_OPEN_AND_CLOSE_FINGER_ID:
                case BleUtils.APP_OPEN_AND_CLOSE_PWD_ID:
                    return new OperKey(response);
                case BleUtils.APP_ADMIN_AUTHORITY_OPER_ID:
                    return new OperAdmin(response);
                case BleUtils.Remote_Upgrade_ACK_ID:
                    return new RemoteUpgradeACK(response);
                case BleUtils.APP_Send_Upgrade_Pkt_ACK_ID:
                    return new UpdatePktACK(response);
                case BleUtils.APP_Upgrade_complete_ACK_ID:
                    return new LockUpgradeComplete(response);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
